import { Works } from '@libs/db/models/works.model';
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ReturnModelType } from '@typegoose/typegoose';
import { Crud } from 'nestjs-mongoose-crud/dist/crud.decorator';
import { InjectModel } from 'nestjs-typegoose/dist/typegoose.decorators';

@Crud({
    model: Works
})
@Controller('works')
@ApiTags('作品')
export class WorksController {

    constructor(@InjectModel(Works) private readonly model: ReturnModelType<typeof Works>) { }

    @Get('option')
    option() {
        return {
            title: '作品管理',
            border: true,
            searchMenuSpan: 8,
            column: [
                {
                    prop: 'author',
                    label: '作者',
                    search: true
                },
                {
                    prop: 'title',
                    label: '作品名'
                },
                {
                    prop: 'category',
                    label: '类别',
                    type: "select",
                    dicData: [
                        {
                            label: '记录片',
                            value: '记录片'
                        },
                        {
                            label: '人物',
                            value: '人物'
                        },
                        {
                            label: '猎奇',
                            value: '猎奇'
                        },
                        {
                            label: '观点',
                            value: '观点'
                        }
                    ],
                    search: true
                },
                {
                    prop: 'cover',
                    label: '封面',
                    span: 24,
                    type: 'upload',
                    listType: 'picture-img',
                    tip: '只能上传jpg/png用户头像，且不超过500kb',
                    action: 'http://localhost:3009/upload'
                },
                {
                    prop: 'synopsis',
                    label: '简介',
                },
                {
                    prop: 'video',
                    label: '视频',
                    span: 24,
                    type: 'upload',
                    listType: 'picture-img',
                    action: 'http://localhost:3009/upload'
                },
                {
                    prop: 'link',
                    label: '链接',
                    type: 'url',
                    dataType: 'string'
                },
            ]
        }
    }
}
